<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>车型信息录入</title>
<style type="text/css">
	table{
		width:100%;
		border: 1px solid black;
	}
	td,th{
		padding: 5px;
	}
	tr{
		line-height: 40px;
	}
	form{
		width:700px;
		margin: 0 auto;
	}
</style>
<script type="text/javascript" src="${basePath }/js/jquery-1.8.2.min.js"></script>
<script src="${basePath }/js/vendor/jquery.ui.widget.js"></script>
<script src="${basePath }/js/jquery.iframe-transport.js"></script>
<script src="${basePath }/js/jquery.fileupload.js"></script>

<script type="text/javascript">
	$(function() {
		$('input[type="file"]').fileupload({
	        url: '${basePath}/fileupload',
	        dataType: 'json',
	        done: function (e, data) {
	        	var result = data._response.result;
	            if(result.isSuccess) {
	            	alert("上传成功！！");
	            	$(this).next().val("${basePath}/upload/"+result.msg);
	            } else {
	            	alert("上传失败！！");
	            }
	        }
	    })
	})
	function addCar() {
		var id = $("form").find("input[name='car.id']").val();
		if(id==null||id=='') {
			alert("代码不能为空！！");
			return;
		}
		$.ajax({
			url:"${basePath}/car/add",
			type:"post",
			data:$("form").serialize(),
			dataType:"json"
		}).done(function(data){
			alert(data.msg);
			if(data.isSuccess)
				window.location = "${basePath}/car/list";
		})
	}
</script>
</head>
<body>
	<h2 align="center">后台管理</h2>
	<hr>
	<form>
		<fieldset>汽车信息录入</fieldset>
		<br>
		<table>
			<tr>
				<th>代码</th><td><input type="text" name="car.id"></td>
				<th>车名</th><td><input type="text" name="car.name"></td>
			</tr>
			<tr>
				<th>品牌</th><td><input type="text" name="car.pp"></td>
				<th>车系</th><td><input type="text" name="car.cx"></td>
			</tr>
			<tr>
				<th>年代款</th><td><input type="text" name="car.ndk"></td>
				<th>配置款</th><td><input type="text" name="car.pzk"></td>
			</tr>
			<tr>
				<th>座位数</th><td><input type="text" name="car.zws"></td>
				<th>车门数</th><td><input type="text" name="car.cms"></td>
			</tr>
			<tr>
				<th>燃料类型</th><td><input type="text" name="car.rllx"></td>
				<th>变速箱类型</th><td><input type="text" name="car.bsxlx"></td>
			</tr>
			<tr>
				<th>排量</th><td><input type="text" name="car.pl"></td>
				<th>燃油标号</th><td><input type="text" name="car.rybh"></td>
			</tr>
			<tr>
				<th>驱动方式</th><td><input type="text" name="car.qdfs"></td>
				<th>发动机进气方式</th><td><input type="text" name="car.fdjjqxs"></td>
			</tr>
			<tr>
				<th>天窗</th><td><input type="text" name="car.tc"></td>
				<th>油箱容量</th><td><input type="text" name="car.yxrl"></td>
			</tr>
			<tr>
				<th>音响</th><td><input type="text" name="car.yx"></td>
				<th>座椅</th><td><input type="text" name="car.zy"></td>
			</tr>
			<tr>
				<th>倒车雷达</th><td><input type="text" name="car.dcld"></td>
				<th>气囊</th><td><input type="text" name="car.qn"></td>
			</tr>
			<tr>
				<th>DVD/CD</th><td><input type="text" name="car.dvdcd"></td>
				<th>GPS导航</th><td><input type="text" name="car.gps"></td>
			</tr>
			<tr>
				<th>视频地址</th><td><input type="text" name="car.swf"></td>
				<th>容纳人数</th><td><input type="text" name="carInfo.num"></td>
			</tr>
			<tr>
				<th>描述词1</th><td><input type="text" name="carInfo.word1"></td>
				<th>描述词2</th><td><input type="text" name="carInfo.word2"></td>
			</tr>
			<tr>
				<th>描述词3</th><td><input type="text" name="carInfo.word3"></td>
				<th>描述词4</th><td><input type="text" name="carInfo.word4"></td>
			</tr>
			<tr>
				<th>图片1</th><td><input type="file" id="file1"><input type="text" name="carInfo.img1" readonly="readonly"></td>
				<th>图片2</th><td><input type="file" id="file2"><input type="text" name="carInfo.img2" readonly="readonly"></td>
			</tr>
			<tr>
				<th>图片3</th><td><input type="file" id="file3"><input type="text" name="carInfo.img3" readonly="readonly"></td>
				<th>图片4</th><td><input type="file" id="file4"><input type="text" name="carInfo.img4" readonly="readonly"></td>
			</tr>
			<tr>
				<th>图片5</th><td><input type="file" id="file5"><input type="text" name="carInfo.img5" readonly="readonly"></td>
				<th>图片6</th><td><input type="file" id="file6"><input type="text" name="carInfo.img6" readonly="readonly"></td>
			</tr>
			<tr>
				<th>图片7</th><td><input type="file" id="file7"><input type="text" name="carInfo.img7" readonly="readonly"></td>
			</tr>
		</table>
		<br>
		<input type="button" value="提交" onclick="addCar();">
	</form>
</body>
</html>